package com.tlias.exam.controller;

import com.tlias.exam.utils.ALiYunOssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * TODO
 *
 * @Author mr.luo
 * @Date 29 4月 2025 17:19
 */
@RestController
public class FileUploadController {
    @Autowired
    private ALiYunOssUtil aLiYunOssUtil;

    @PostMapping("/upload")
    public String upload(MultipartFile file) throws Exception {
        String originalFilename = file.getOriginalFilename();
        byte[] bytes = file.getBytes();
        String url = aLiYunOssUtil.uploadFile(bytes, originalFilename);
        return url;
    }
}
